<?php
// +----------------------------------------------------------------------
// | Tplay [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://tplay.pengyichen.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 听雨 < 389625819@qq.com >
// +----------------------------------------------------------------------


namespace app\admin\model;

use \think\Model;
use \think\Cookie;
class ArticleComment extends Model
{

public function member(){

    return $this->belongsTo('Member');

}

    public function article(){

        return $this->belongsTo('Article');

    }
    public function admin(){

        return $this->belongsTo('Admin');

    }

    public function del($t=''){
    $a='';
    if ($t!=''){
       $b= $this->where('comment_id',$t)->delete();
        if ($b==true){
            $a=true;
            return $a;
        }else {
            $a=false;
            return $a;
        }
    }else{

    }

        $a=false;
        return $a;

    }

public function review($t=''){

    $a='';
    $adminid = Cookie::get('admin');
    if ($t!=''){

        if ($t['comment_status']==1){

            $b= $this->where('comment_id',$t['id'])->update(
                ['comment_status'=>2,
                    'updatetime'=>time(),
                    'admin_id'=>$adminid
                ]

            );
        }else if($t['comment_status']==2){
            $b= $this->where('comment_id',$t['id'])->update(
                ['comment_status'=>1,
                    'updatetime'=>time(),
                    'admin_id'=>$adminid
                ]

            );
        }



        if ($b==true){
            $a=true;
            return $a;
        }else {
            $a=false;
            return $a;
        }
    }else{

    }

    $a=false;
    return $a;




}




}
